﻿#pragma once

#include <E_EquipStrengthData.nanopb.h>
#include <DescStore/EquipStrengthDesc.h>

#include "NFServerComm/NFServerCommon/NFIDescStoreEx.h"
#include "NFServerComm/NFServerCommon/NFIDescTemplate.h"
#include "NFComm/NFObjCommon/NFResDb.h"
#include "NFComm/NFObjCommon/NFShmMgr.h"
#include "NFComm/NFShmStl/NFShmHashMap.h"
#include "NFComm/NFShmStl/NFShmVector.h"
#include "NFLogicCommon/NFDescStoreTypeDefines.h"

struct EquipStrengthQualityPartStrengthLevelEquipLevel
{
	EquipStrengthQualityPartStrengthLevelEquipLevel()
	{
		if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
		{
			CreateInit();
		}
		else
		{
			ResumeInit();
		}
	}

	int CreateInit()
	{
		quality = 0;
		part = 0;
		strength_level = 0;
		equip_level = 0;
		return 0;
	}

	int ResumeInit()
	{
		return 0;
	}

	int32_t quality;
	int32_t part;
	int32_t strength_level;
	int32_t equip_level;

	bool operator==(const EquipStrengthQualityPartStrengthLevelEquipLevel& data) const
	{
		return quality == data.quality && part == data.part && strength_level == data.strength_level && equip_level == data.equip_level;
	}

	std::string ToString() const
	{
		std::stringstream ios;
		ios << quality;
		ios << ",";
		ios << part;
		ios << ",";
		ios << strength_level;
		ios << ",";
		ios << equip_level;
		return ios.str();
	}
};

namespace std
{
	template <>
	struct hash<EquipStrengthQualityPartStrengthLevelEquipLevel>
	{
		size_t operator()(const EquipStrengthQualityPartStrengthLevelEquipLevel& data) const
		{
			return NFHash::hash_combine(data.quality, data.part, data.strength_level, data.equip_level);
		}
	};
}

class EquipStrengthDataDescEx : public NF_OBJECT_GLOBAL_TEMPLATE_MACRO(EquipStrengthDataDescEx, EOT_CONST_EQUIPSTRENGTHDATA_DESC_EX_ID, NFIDescStoreEx)
public:
	EquipStrengthDataDescEx();
	virtual ~EquipStrengthDataDescEx();
	int CreateInit();
	int ResumeInit();

public:
	virtual int Load() override;
	virtual int CheckWhenAllDataLoaded() override;

public:
	const E_EquipStrength* GetDesc(int iStrengthLevel, int iEquipDescID) const;
private:
	NFShmHashMap<EquipStrengthQualityPartStrengthLevelEquipLevel, uint64_t, MAX_EQUIPSTRENGTHDATA_EQUIPSTRENGTHCOST_NUM*30> m_QualityPartStrengthLevelEquipLevelComIndexMap;
};
